package zz.demo.springCloud.wechat.utils;

import me.chanjar.weixin.cp.api.WxCpService;
import org.springframework.stereotype.Component;
import zz.demo.springCloud.wechat.config.WxCpServiceAdapter;

/**
 * Created by zhangzheng on 2017-11-9.
 */
@Component
public class CommonUtils {
    public boolean isNull(Integer o){
        return o==null?true:false;
    }

    public boolean isNull(String o){
        return (o==null||o.isEmpty())?true:false;
    }

    /*
        有空则返回false
     */
    public boolean isNotNull(String... o){
        boolean flag = true;
        for (String s : o) {
            flag = flag && isNotNull(s);
        }
        return flag;
    }

    public boolean isNotNull(Integer o){
        return !isNull(o);
    }

    public boolean isNotNull(String o){
        return !isNull(o);
    }

    public WxCpServiceAdapter getService(WxCpService weixinService){
        try {
            return (WxCpServiceAdapter) weixinService;
        }catch (ClassCastException e){
            e.printStackTrace();
        }
        return null;
    }
}
